﻿@model Blog.Models.ArticleIndexViewModel
@{
    ViewBag.Title = "Articles";

    int numberPage = 1;
}

<div class="container">
    <h2>@ViewBag.Message</h2>
    <h3>Articles : </h3><hr /><br />
    
    @if (Request.IsAuthenticated)
    { 
        <a href="/Articles/Create" class="btn btn-primary btn-medium"><i class="icon-plus icon-white"></i> Ajouter un article</a>
    }<br />

    <div class="pagination pagination-centered">
        <ul>
            <li><a href="/Articles/Index/1">Première</a></li>
            @for (int i = 1; i < ((int)Math.Ceiling((decimal)Model.NbArticles / 5)) + 1; i++)
            {
                <li><a href="/Articles/Index/@i">@i</a></li>
                numberPage = i;
            }
            <li><a href="/Articles/Index/@numberPage">Dernière</a></li>     
        </ul>
    </div>

    @foreach (DAL.Article article in Model.Articles)
    {
        <h3><a href="/Articles/Details/@article.ID">@article.Title</a> [ <a href="/Categories/Details/@article.Category.ID" id="@article.ID" rel="popover" data-content="@article.Category.Description" data-original-title="Description"> @article.Category.Name </a> ]</h3><br />
    
        <div class="well">
            @if (article.Content.Length > 255)
            {
                @article.Content.ToString().Substring(0, 255); @:(...)
            }
            else
            {
                @article.Content
            }
        </div>
    
        <p>
            <link rel="canonical" href="/Articles/Details/@article.ID" />
            <g:plusone size="medium"></g:plusone>
            <a href="/Articles/Details/@article.ID" class="twitter-share-button" data-lang="fr">Tweet</a>
            <fb:like href="/Articles/Details/@article.ID" send="false" layout="button_count" width="450" show_faces="false"></fb:like>
        </p><br />
        
        <script src="@Url.Content("~/Scripts/bootstrap-transition.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/jquery.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/bootstrap-tooltip.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/bootstrap-popover.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/bootstrap-validation.js")" type="text/javascript"></script>

        <script type="text/javascript">
        $(function () {
            $("#@article.ID").popover({ placement: 'right' });
        });  
        </script> 
    }

    <div class="pagination pagination-centered">
        <ul>
            <li><a href="/Articles/Index/1">Première</a></li>
            @for (int i = 1; i < ((int)Math.Ceiling((decimal)Model.NbArticles / 5)) + 1; i++)
            {
                <li><a href="/Articles/Index/@i">@i</a></li>
            }
            <li><a href="/Articles/Index/@numberPage">Dernière</a></li>
        </ul>
    </div>
</div>